<?php

namespace app\api\model;

use app\api\service\Api;
use think\Db;
use think\Request;

class OrderCorrectRecordModel extends Api
{
    protected static $instance;

    public function __construct(Request $request = null)
    {
        parent::__construct($request);
    }

    public static function getInstance()
    {
        if (is_null(self::$instance))
        {
            self::$instance = new static();
        }
        return self::$instance;
    }

    /**
     * 插入一条记录
     */
    public function insert($data)
    {
        Db::name('order_correct_record')->insert($data);
        return Db::name('order_correct_record')->getLastInsID();
    }

    /**
     * 获取多条记录
     */
    public function select($where, $field = '*', $start = 0, $limit = 1000000, $whereOr = '')
    {
        return Db::name('order_correct_record')->where($where)->whereOr($whereOr)->field($field)->limit($start, $limit)->select();
    }

    public function count($where, $whereOr)
    {
        return Db::name('order_correct_record')->where($where)->whereOr($whereOr)->count();
    }

    /**
     * 获取一条记录
     */
    public function find($where, $field = '*')
    {
        return Db::name('order_correct_record')->where($where)->field($field)->find();
    }

    /**
     * 获取一个记录
     */
    public function value($where, $field = 'correct_file')
    {
        return Db::name('order_correct_record')->where($where)->value($field);
    }

    /**
     * 修改一条记录
     */
    public function update($where, $data)
    {
        return Db::name('order_correct_record')->where($where)->update($data);
    }

    /**
     * 获取一列数据
     */
    public function column($where, $field = 'num_id')
    {
        return Db::name('order_correct_record')->where($where)->column($field, 'id');
    }
}